Skip to content

allow ctx.run(ctx => {...})#231

Draft
ianmacartney wants to merge 3 commits intomainfrom
ian/inline-ctx-run
Draft

allow ctx.run(ctx => {...})#231
ianmacartney wants to merge 3 commits intomainfrom
ian/inline-ctx-run

Conversation

@ianmacartney
Copy link
Copy Markdown
Member

@ianmacartney ianmacartney commented Apr 2, 2026

Add inline handler support to workflow context

This change introduces a new ctx.run() method that allows executing inline handlers within workflow mutation transactions. The handler receives the mutation context and can perform database operations, with results being journaled for replay consistency.

Key Changes

  • Added ctx.run() method to WorkflowCtx that executes inline handlers with access to the mutation context
  • Introduced optional internalMutation parameter to workflow definitions for fully typed database access
  • Added generic DataModel type parameter to WorkflowDefinition and WorkflowCtx for type safety
  • Extended step execution to handle inline handlers alongside existing function calls
  • Updated journal processing to support inline-completed steps
  • Added comprehensive test coverage for inline handler execution, replay, and error handling

The inline handlers are journaled like other workflow steps, ensuring deterministic replay behavior while providing direct access to the underlying mutation transaction.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 2, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 44c81e60-3f4b-4b33-9830-a9152cceb4e9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ian/inline-ctx-run

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ianmacartney ianmacartney changed the title allow ctx.run allow ctx.run(ctx => {...}) Apr 2, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 2, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@convex-dev/workflow@231

commit: ae4c041

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant